<template>
  <el-form size="mini" :rules="tfrom.rue" :model="tfrom" ref="fromDome">
    <el-table size="mini" :data="tfrom.Dataorigins" ref="tableT" empty-text=" " :header-cell-style="{ background: '#F5F5F5', color: '#000000' }" style="width: 100%">
      <el-table-column v-for="(headers, index) in table.header" :prop="headers.prop" :label="headers.name" :key="index" :width="headers.width" :sortable="headers.sortable">
        <template #default="scope">
          <span v-html="scope.row[headers.prop]"></span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" :width="table.operationW" v-if="table.isoperation">
        <template #default="scope">
          <el-button size="mini" v-for="(item, index) in table.operationList[scope.row[table.StatusField != undefined ? table.StatusField : 'status']]" type="text" @click="childByValue(scope.row, item)" :key="index">{{ item }} </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-form>
</template>

<script>
export default {
  data() {
    return {
      tfrom: {
        Dataorigins: [],
      },
    }
  },
  props: ['table'],
  mounted() {},
  methods: {
    // 表格按钮回调
    // 单元格中的输入框、开关、下拉菜单等给父级传值的方法
    childByValue(row, index, e) {
      this.$emit('tableFuncCellback', [row, index], e)
    },
  },
  watch: {
    // 监听表格变化
    'table.Dataorigin': {
      handler(newVal, oldVal) {
        this.tfrom.Dataorigins = newVal
      },
    },
  },
}
</script>
